package com.bupt.ilink.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {

    //文档上传对应的线程池
    @Bean(name = "fileUploadTaskExecutor")
    public ThreadPoolExecutor fileUploadTaskExecutor() {
        return new ThreadPoolExecutor(10, 25, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5000));
    }

    //文档处理对应的线程池
    @Bean(name = "fileHandleTaskExecutor")
    public ThreadPoolExecutor fileHandleTaskExecutor() {
        return new ThreadPoolExecutor(5, 15, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5000));
    }
    //音视频转写回调状态查询的线程池
    @Bean(name = "checkVideoTaskExecutor")
    public ThreadPoolExecutor checkVideoTaskExecutor() {
        return new ThreadPoolExecutor(1, 5, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5000));
    }
    //音视频加工的线程池
    @Bean(name = "videoHandleTaskExecutor")
    public ThreadPoolExecutor videoHandleTaskExecutor() {
        return new ThreadPoolExecutor(5, 10, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5000));
    }

}
